﻿using HandyControl.Controls;
using Ping9719.WpfEx;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BaseUi.Views.PlcView
{
    /// <summary>
    /// ColdBoxTakeTwoView.xaml 的交互逻辑冷库取放点2页面
    /// </summary>
    public partial class ColdBoxTakeTwoView : UserControlBase
    {
        public ColdBoxTakeTwoView()
        {
            InitializeComponent();
        }

        private void loadFirst(object sender, EventArgs e)
        {
            if (this.IsInDesignMode)
                return;
            GetnewColdt();
        }

        private void coldtwoboxButton_Click(object sender, RoutedEventArgs e)
        {
            GetnewColdt();
        }

        private void GetnewColdt()
        {
            var ioi = LocalStatic.Plc.Read<float>("1192");
            if (ioi.IsSucceed==false)
            {
                ColdtwoBox1g1.Text = "未接收";
            }
            else
            {
                ColdtwoBox1g1.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1194");
            if (ioi.IsSucceed == false)
            {
                ColdtwoBox1g2.Text = "未接收";
            }
            else
            {
                ColdtwoBox1g2.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1254");
            if (ioi.IsSucceed == false)
            {
                ColdtwoBox1g3.Text = "未接收";
            }
            else
            {
                ColdtwoBox1g3.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1256");
            if (ioi.IsSucceed == false)
            {
                ColdtwoBox1g4.Text = "未接收";
            }
            else
            {
                ColdtwoBox1g4.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1258");
            if (ioi.IsSucceed == false)
            {
                ColdtwoBox1g5.Text = "未接收";
            }
            else
            {
                ColdtwoBox1g5.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1260");
            if (ioi.IsSucceed == false)
            {
                ColdtwoBox1g6.Text = "未接收";
            }
            else
            {
                ColdtwoBox1g6.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1262");
            if (ioi.IsSucceed == false)
            {
                ColdtwoBox1g7.Text = "未接收";
            }
            else
            {
                ColdtwoBox1g7.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1264");
            if (ioi.IsSucceed == false)
            {
                ColdtwoBox1g8.Text = "未接收";
            }
            else
            {
                ColdtwoBox1g8.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1266");
            if (ioi.IsSucceed == false)
            {
                ColdtwoBox1g9.Text = "未接收";
            }
            else
            {
                ColdtwoBox1g9.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1268");
            if (ioi.IsSucceed == false)
            {
                ColdtwoBox2g1.Text = "未接收";
            }
            else
            {
                ColdtwoBox2g1.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1270");
            if (ioi.IsSucceed == false)
            {
                ColdtwoBox2g2.Text = "未接收";
            }
            else
            {
                ColdtwoBox2g2.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1198");
            if (ioi.IsSucceed == false)
            {
                ColdtwoBox2g3.Text = "未接收";
            }
            else
            {
                ColdtwoBox2g3.Text = ioi.Value.ToString();
            }
            ioi = LocalStatic.Plc.Read<float>("1226");
            if (ioi.IsSucceed == false)
            {
                ColdtwoBox2g4.Text = "未接收";
            }
            else
            {
                ColdtwoBox2g4.Text = ioi.Value.ToString();
            }
            //ColdtwoBox1g1.Text=LocalStatic.Plc.Read<float>("1192").Value.ToString();
            //ColdtwoBox1g2.Text = LocalStatic.Plc.Read<float>("1194").Value.ToString();
            //ColdtwoBox1g3.Text = LocalStatic.Plc.Read<float>("1254").Value.ToString();
            //ColdtwoBox1g4.Text = LocalStatic.Plc.Read<float>("1256").Value.ToString();
            //ColdtwoBox1g5.Text = LocalStatic.Plc.Read<float>("1258").Value.ToString();
            //ColdtwoBox1g6.Text = LocalStatic.Plc.Read<float>("1260").Value.ToString();
            //ColdtwoBox1g7.Text = LocalStatic.Plc.Read<float>("1262").Value.ToString();
            //ColdtwoBox1g8.Text = LocalStatic.Plc.Read<float>("1264").Value.ToString();
            //ColdtwoBox1g9.Text = LocalStatic.Plc.Read<float>("1266").Value.ToString();
            //ColdtwoBox2g1.Text = LocalStatic.Plc.Read<float>("1268").Value.ToString();
            //ColdtwoBox2g2.Text = LocalStatic.Plc.Read<float>("1270").Value.ToString();
            //ColdtwoBox2g3.Text = LocalStatic.Plc.Read<float>("1198").Value.ToString();
            //ColdtwoBox2g4.Text = LocalStatic.Plc.Read<float>("1226").Value.ToString();
        }

        private void Label_ColdtwoBoxDoubleClick1g1(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdtwoBox1g1.Text);
                var ioi = LocalStatic.Plc.Write<float>("1192", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }

        }

        private void Label_ColdtwoBoxDoubleClick1g2(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdtwoBox1g2.Text);
                var ioi = LocalStatic.Plc.Write<float>("1194", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdtwoBoxDoubleClick1g3(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdtwoBox1g3.Text);
                var ioi = LocalStatic.Plc.Write<float>("1254", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdtwoBoxDoubleClick1g4(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdtwoBox1g4.Text);
                var ioi = LocalStatic.Plc.Write<float>("1256", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdtwoBoxDoubleClick1g5(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdtwoBox1g5.Text);
                var ioi = LocalStatic.Plc.Write<float>("1258", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdtwoBoxDoubleClick1g6(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdtwoBox1g6.Text);
                var ioi = LocalStatic.Plc.Write<float>("1260", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdtwoBoxDoubleClick1g7(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdtwoBox1g7.Text);
                var ioi = LocalStatic.Plc.Write<float>("1262", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdtwoBoxDoubleClick1g8(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdtwoBox1g8.Text);
                var ioi = LocalStatic.Plc.Write<float>("1264", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdtwoBoxDoubleClick1g9(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdtwoBox1g9.Text);
                var ioi = LocalStatic.Plc.Write<float>("1266", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdtwoBoxDoubleClick2g1(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdtwoBox2g1.Text);
                var ioi = LocalStatic.Plc.Write<float>("1268", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdtwoBoxDoubleClick2g2(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdtwoBox2g2.Text);
                var ioi = LocalStatic.Plc.Write<float>("1270", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdtwoBoxDoubleClick2g3(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdtwoBox2g3.Text);
                var ioi = LocalStatic.Plc.Write<float>("1198", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }

        private void Label_ColdtwoBoxDoubleClick2g4(object sender, MouseButtonEventArgs e)
        {
            try
            {
                float fait = float.Parse(ColdtwoBox2g4.Text);
                var ioi = LocalStatic.Plc.Write<float>("1226", fait);
                if (ioi.IsSucceed == false)
                {
                    Growl.Error("上传失败");
                }
            }
            catch (Exception ee)
            {
                Growl.Error(ee.ToString());
            }
        }
    }
}
